#pragma once
#include <functional>
#include <string>
#include <thread>
#include "XnccType.h"

namespace xncc {
namespace foundation {
    class PThread
    {
      public:
        using ThreadFunc = std::function<void()>;

        PThread(ThreadFunc func, std::string name, types::thread_id_t tid, int coreId = -1);
        PThread(const PThread&)             = delete;
        PThread(const PThread&&)            = delete;
        PThread& operator=(const PThread&)  = delete;
        PThread& operator=(const PThread&&) = delete;
        ~PThread();
        void start();
        void join();

      private:
        void runInThread();

        ThreadFunc               func_;
        std::string              name_;
        std::thread              t_;
        const types::thread_id_t id_;      // 自定义线程id
        const int                coreId_;  // 线程绑核的ID
    };
}  // namespace foundation
}  // namespace xncc